import * as api from '@/axios/api'
import axios from '@/axios/axiosConfig'
import * as types from './mutation-types'
import { Message  } from 'element-ui'

/**
 * 异步操作  提交的是 mutation
 *  
 */
export const getSchoolList = ({ commit }) => {
    // 获取学校列表
    axios.get(api.getSchoolList).then((response) =>{
        if (response.data.success) {
            commit(types.SET_SCHOOL_LIST, response.data.data);
        } else {
            Message({
                message: response.data.msg,
                type: 'error'
            });
        }
    })

}
export const getDictListByType = ({ commit }, payload) => {
    vm.axios.get(api.dictsTypesSubListUrl, {
        params: {
           type: payload,
       }
   }).then((response) =>{
        if (response.data.success) {
            commit(types.SET_DICT_LIST, response.data.data);
        } else {
            Message({
                message: response.data.msg,
                type: 'error'
            });
        }
    })
}

export const getUserList_No = ({ commit }) => {
    // 获取用户列表
    axios.get(api.userManagement.userList_no).then((response) =>{
        if (response.data.code == 200) {
            commit(types.SET_USER_NO_LIST, response.data.data);
        } else {
            Message({
                message: response.data.msg,
                type: 'error'
            });
        }
    })

}